package com.ruibang.glass.material.service.impl.rq;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.material.domain.req.rq.ContainerStalesReq;
import com.ruibang.glass.material.entity.rq.MaterialContainerStaleStatistics;
import com.ruibang.glass.material.mapper.rq.MaterialContainerStaleStatisticsMapper;
import com.ruibang.glass.material.service.rq.GMaterialContainerStaleStatisticsService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 容器呆滞统计 服务实现类
 * </p>
 *
 * @author mameng
 * @since 2024-04-02
 */
@Service
public class MaterialContainerStaleStatisticsServiceImpl extends ServiceImpl<MaterialContainerStaleStatisticsMapper, MaterialContainerStaleStatistics> implements GMaterialContainerStaleStatisticsService {

    @Override
    public IPage<MaterialContainerStaleStatistics> getPage(ContainerStalesReq containerStalesReq) {
        LambdaQueryWrapper<MaterialContainerStaleStatistics> queryWrapper = Wrappers.<MaterialContainerStaleStatistics>lambdaQuery();
        if (StringUtils.isNotBlank(containerStalesReq.getContainerCode())) {
            queryWrapper.like(MaterialContainerStaleStatistics::getContainerCode, containerStalesReq.getContainerCode());
        }
        if (StringUtils.isNotBlank(containerStalesReq.getContainerType())) {
            queryWrapper.like(MaterialContainerStaleStatistics::getContainerType, containerStalesReq.getContainerType());
        }
        if (StringUtils.isNotBlank(containerStalesReq.getStatus())) {
            queryWrapper.eq(MaterialContainerStaleStatistics::getStatus, containerStalesReq.getStatus());
        }
        if (StringUtils.isNotBlank(containerStalesReq.getStorageLocation())) {
            queryWrapper.eq(MaterialContainerStaleStatistics::getStorageLocation, containerStalesReq.getStorageLocation());
        }
        if (StringUtils.isNotBlank(containerStalesReq.getWarehouseName())) {
            queryWrapper.eq(MaterialContainerStaleStatistics::getWarehouseId, containerStalesReq.getWarehouseName());
        }
        Page<MaterialContainerStaleStatistics> materialWarehouseInfoPage = baseMapper.selectPage(new Page<>(containerStalesReq.getPageNo(), containerStalesReq.getPageSize()),
                queryWrapper.orderByDesc(MaterialContainerStaleStatistics::getCreateTime)
        );
        return materialWarehouseInfoPage;
    }

    @Override
    public IPage<MaterialContainerStaleStatistics> getRqLocationStatics(ContainerStalesReq containerStalesReq) {
        return null;
    }

}
